package com.midea.iot.privateLessons.disruptor; 

import com.google.gson.Gson;
import com.lmax.disruptor.ExceptionHandler;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * @author xingwuxw
 * @Description
 * @create 2022-05-02
 */
public class MessageExceptionHandler implements ExceptionHandler<MessageEvent> {

    private static final Logger logger = LoggerFactory.getLogger(MessageExceptionHandler.class);
    private static Gson gson = new Gson();

    @Override
    public void handleEventException(Throwable throwable, long l, MessageEvent event) {
        logger.error("处理异常数据：{}, 异常信息：{}", gson.toJson(event), throwable);
    }

    @Override
    public void handleOnStartException(Throwable throwable) {
        logger.info("开始处理异常...");
    }

    @Override
    public void handleOnShutdownException(Throwable throwable) {
        logger.info("异常处理结束.");
    }
}